// /////////////////////////////////////////////////////////////////////////////
// g6 group ////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
$.fn.getG6data = function(_lotto_id,_gametype){
 $().disAreaObj();
 $.getJSON('op.php?op=xml_3d&fp=rate_3d&playtype=g6&lotto_id_3d='+_lotto_id+"&gametype="+_gametype+"&disk="+ $("select#slcDisk").val() ,function(ratedata){
      var dataLen = 0;
      var urlPre = "";
      var hrefStr = "";
      if(ratedata.errormsg != undefined){
        $("div#errormsg").addClass("error").text("No Rate data");
      }else{
          $().creatRateData(ratedata.r30, '30');
          $().creatRateData(ratedata.r31, '31');
          $().creatRateData(ratedata.r32, '32');
          $().creatRateData(ratedata.r33, '33');
          $().creatRateData(ratedata.r34, '34');
          $("div#errormsg").text("");
          $("div#mainPageData").show();
          
          // bind here for chinese word
          $(".sel").bind('click',function(){//tr>td>input:checkbox
		    var o=$(this).find("input");
			if(o.attr("checked",o.attr("checked")==false))
            o.showChkMsg();
          });
      }
      $().redisAreaObj();
  });
};


// create table data
$.fn.creatRateData = function(rdata, rnum){
    var dataLen = rdata.number.length;
    var tbd = "tbody#tbdr"+rnum;
    $(tbd).empty();
    for(i = 0; i < dataLen; i++){
       $('<tr class="td2" align=center><th class="gtdnum title02_3d"">'+rdata.number[i]+'</th><td class="betnum"><span class="betRateNum">'+rdata.rates[i]+'</span></td><td class="sel"><input style="display:none" type="checkbox" size="3" value="'+rdata.number[i]+'" name="r'+rnum+'[]" /></td></tr>').appendTo(tbd);
    }
};

// count how many groups
$.fn.countGroups = function(typenum, num){
  var reval = 0;
  
  if(typenum == num){ 
    return 1;
  }else{
    var cut = num - typenum;
    reval = 1;
    for(i = 0; i < cut; i++){
      reval *= (num - i);
    }
    return reval; 
  }

};